﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ForumServer.Forum
{
    [Serializable]
    public class Post
    {
        string _header;
        string _content;
        DateTime _timeStamp;
        User _user;


        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="header">The header describing the post</param>
        /// <param name="content">The content (body) of the new post</param>
        /// <param name="timeStamp">The exact time when the post has published</param>
        public Post(string header, string content, DateTime timeStamp, User user)
        {
            this._header = header;
            this._content = content;
            this._timeStamp = timeStamp;
            this._user = user;
        }
        public string Header { get { return _header; } set { _header = value; } }
        public string Content { get { return _content; } set { _content = value; } }
        public DateTime TimeStamp { get { return _timeStamp; } set { _timeStamp = value; } }
        public User User { get { return _user; } set { _user = value; } }

        public String getPostDetails()
        {
            String details = _header + '\n';
            details += _content + '\n';
            details += "Created at: " + _timeStamp.ToString() + '\n';
            details += "By: " + _user.Username + '\n';
            return details; 
        }

        public override String ToString()
        {
            String post = "\n\n";
           // post += "------------------------------------------------\n";
            post += _header + "\n\n";
            post += "by " + _user.Username+ " >> " + _timeStamp.ToString() + "\n\n";
            post += Content + "\n";
            post += "------------------------------------------------\n\n";
            return post;
        }
    }
}
